//
//  KTiltleAndInputTableViewCell.m
//  Peanut
//
//  Created by Jim huang on 2018/3/18.
//  Copyright © 2018年 Jim_Peanut. All rights reserved.
//

#import "KTiltleAndInputTableViewCell.h"

@interface KTiltleAndInputTableViewCell ()<UITextFieldDelegate>


@end

@implementation KTiltleAndInputTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUI];
    }
    return self;
}

-(void)setUI{
    
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(20);
        
    }];
    
    [self.inputTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(100);
        make.centerY.equalTo(self);
        make.right.equalTo(self).offset(-30);
        make.height.equalTo(@50);
    }];
}


-(void)textFieldDidEndEditing:(UITextField *)textField{
    if (self.textChangeBlock) {
        self.textChangeBlock(textField.text);
    }
}

#pragma mark ---- getting&setting----

//标题
-(UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.textColor = kTextBlackColor;
        _titleLabel.font = kFont(14);
        [self addSubview:_titleLabel];
    }
    return _titleLabel;
}

//输入框
-(UITextField *)inputTextField{
    if (!_inputTextField) {
        _inputTextField = [[UITextField alloc]init];
        _inputTextField.textColor = kTextBlackColor;
        _inputTextField.font = kFont(14);
        _inputTextField.delegate = self;
        [self addSubview:_inputTextField];
    }
    return _inputTextField;
}




- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
